<template>
  <div class="cart">
    <nav-bar class="nav-bar">
      <template #center>
        购物车({{ cartLength }})
      </template>
    </nav-bar>

    <!-- 商品列表 -->
    <scroll class="cart-scroll" ref="scroll">
      <template #default>
        <cart-list></cart-list>
      </template>
    </scroll>

    <!-- 底部汇总 -->
    <cart-bottom-bar></cart-bottom-bar>

  </div>
</template>

<script>
  import NavBar from 'components/common/navbar/NavBar'
  import Scroll from 'components/common/scroll/Scroll'

  import CartList from './childComps/CartList'
  import CartBottomBar from './childComps/CartBottomBar'

  import { mapGetters } from 'vuex'

  export default {
    name: "Cart",
    components:{
      NavBar,
      CartList,
      Scroll,
      CartBottomBar
    },
    computed: {
      ...mapGetters([
        'cartLength'
      ])
    },
    activated(){
      this.$refs.scroll.refresh()
    }
  }
</script>

<style scoped>
  .cart{
    height: 100vh;
  }
.nav-bar{
  background-color: var(--color-tint);
  color: white;
  font-weight: bold;

  position: relative;
  z-index: 9;
}
  .cart-scroll{
    height: calc(100% - 44px - 49px - 40px);
    overflow: hidden;
  }
</style>
